package com.maya.controller;


import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.maya.model.User;
import com.maya.service.UserService;


@Controller

public class LoginController  {

	@Autowired
	private UserService userService;
	
	
	@RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(String email, String password,HttpSession session){
       
		
        if(password != null && null!=email && "" != email) {
                    	
            User user=userService.findby(email,password);
            if(user!=null) {
            	
            	session.setAttribute("currUser", user);
            }
        }
                
        return "redirect:/viewallquestions";
    }
}
